﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;

namespace GrayParrot.Web.Controls
{
    [Serializable]
    public class Paging : Feature<bool>
    {
        public int PageLength { get; set; }
        public PaginationTypes PagingType { get; set; }

        public Paging()
        {
            this.Value = true;
            this.PageLength = 10;
            this.PagingType = PaginationTypes.SimpleNumbers;
        }

        public override string ToString()
        {
            string retValue = string.Empty;

            retValue = string.Format("\"paging\": {0}\n", this.Value.ToString().ToLower());

            if (this.Value)
            {
                retValue += string.Format(",\"pageLength\": {0}\n", this.PageLength);
                retValue += string.Format(",\"pagingType\": \"{0}\"", EnumHelper.GetDescription(this.PagingType));
            }

            return retValue;
        }
    }
}
